package com.cloudbroker.bcs.common.model;

import java.io.Serializable;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;

import com.alibaba.fastjson.JSON;

public class SessionIdentity implements Serializable {
    
    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = 1L;
    
	
    protected Long leader_id;
	
    protected Long client_id;
    
    protected Long brokerId;
	

    //用户类型
    protected String user_type;
    
    protected String userType;
    
    protected Integer platformType;
    
    protected Set<String> permissions;
    
    protected String brokerLoginType;
    
    protected Integer tenantId;
    
    public String toStringInfo() {
        return JSON.toJSONString(this);
    }
    
    public static SessionIdentity fromStringInfo(String string) {
        if (StringUtils.isNotBlank(string)) {
            return JSON.parseObject(string, SessionIdentity.class);
        }
        return null;
    }
	
	public Long getLeader_id() {
        return leader_id;
    }

    public void setLeader_id(Long leader_id) {
        this.leader_id = leader_id;
    }
    
    public Long getClient_id() {
        return client_id;
    }
    
    public void setClient_id(Long client_id) {
        this.client_id = client_id;
    }
    
    public Long getBrokerId() {
        return brokerId;
    }
    
    public void setBrokerId(Long brokerId) {
        this.brokerId = brokerId;
    }
    
    public String getUserType() {
        return userType;
    }
    
    public void setUserType(String userType) {
        this.userType = userType;
    }
    
    public Set<String> getPermissions() {
        return permissions;
    }
    
    public void setPermissions(Set<String> permissions) {
        this.permissions = permissions;
    }
    
    public Integer getPlatformType() {
        return platformType;
    }
    
    public void setPlatformType(Integer platformType) {
        this.platformType = platformType;
    }
    
	public Set<String> getPermissions() {
        return permissions;
    }

    public void setPermissions(Set<String> permissions) {
        this.permissions = permissions;
    }
	
    public String getBrokerLoginType() {
        return brokerLoginType;
    }
    
    public void setBrokerLoginType(String brokerLoginType) {
        this.brokerLoginType = brokerLoginType;
    }
    
    public String getClientIdKeyEnd() {
        if (StringUtils.isBlank(getBrokerLoginType())) {
            return String.valueOf(this.getClient_id());
        }
        return getBrokerLoginType() + this.getClient_id();
    }
    
    public Integer getTenantId() {
        return tenantId;
    }
    
    public void setTenantId(Integer tenantId) {
        this.tenantId = tenantId;
    }
    
    /**@Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("SessionIdentity [client_id=").append(client_id).append(", brokerId=").append(brokerId)
                .append(", userType=").append(userType).append(", platformType=").append(platformType)
                .append(", permissions=").append(permissions).append(", brokerLoginType=").append(brokerLoginType)
                .append(", tenantId=").append(tenantId).append("]");
        return builder.toString();
    }**/
    
}
